package com.youhome.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.youhome.mapper.HouseVideoMapper;
import com.youhome.model.HouseVideo;
import com.youhome.service.HouseVideoService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * Created by chen365 on 2019/01/27.
 */
@Service
public class HouseVideoServiceImpl implements HouseVideoService {
    @Autowired
    private HouseVideoMapper houseVideoMapper;

    @Override
    public HouseVideo selectByPrimaryKey(String videoId) {
        return houseVideoMapper.selectByPrimaryKey(videoId);
    }

    @Override
    public PageInfo<HouseVideo> selectByBean(Integer pageNumber, Integer pageSize, HouseVideo record) {
        if (StringUtils.isEmpty(pageNumber) || pageNumber < 1) {
            pageNumber = 1;
        }
        if (StringUtils.isEmpty(pageSize) || pageSize < 10) {
            pageSize = 10;
        }
        PageHelper.startPage(pageNumber, pageSize);
        List<HouseVideo> houseVideos = houseVideoMapper.selectByBean(record);
        return new PageInfo<>(houseVideos);
    }
}
